package lzm.upload;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Test {
    public static void main(String[] args) {
        // 确保系统使用 UTF-8 编码
        System.setProperty("file.encoding", "UTF-8");

        // 设置 Look and Feel
        try {
            UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }

        // 创建窗口
        JFrame frame = new JFrame("文件上传和下载");
        frame.setSize(600, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new GridBagLayout());

        // 设置标题
        JLabel title = new JLabel("文件上传和下载");
        title.setFont(new Font("SimSun", Font.BOLD, 24)); // 使用宋体字体
        title.setForeground(Color.decode("#333333"));

        // 创建上传按钮
        JButton uploadButton = new JButton("选择文件上传");
        uploadButton.setFont(new Font("SimSun", Font.BOLD, 14)); // 使用宋体字体
        uploadButton.setBackground(Color.decode("#4CAF50"));
        uploadButton.setForeground(Color.WHITE);
        uploadButton.setFocusPainted(false);

        // 创建下载按钮
        JButton downloadButton = new JButton("选择保存位置下载");
        downloadButton.setFont(new Font("SimSun", Font.BOLD, 14)); // 使用宋体字体
        downloadButton.setBackground(Color.decode("#2196F3"));
        downloadButton.setForeground(Color.WHITE);
        downloadButton.setEnabled(false);

        // 布局设置
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(10, 10, 10, 10);
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.gridwidth = 2;
        frame.add(title, gbc);

        gbc.gridwidth = 1;
        gbc.gridy = 1;
        frame.add(uploadButton, gbc);

        gbc.gridx = 1;
        frame.add(downloadButton, gbc);

        frame.setLocationRelativeTo(null); // 窗口居中
        frame.setVisible(true);
    }
}
